package com.lcz.googleplay.widget;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.lcz.googleplay.R;
import com.lcz.googleplay.activity.BaseActivity;


/**
 * Created by moon.zhong on 2015/6/12.
 * time : 10:26
 */
public abstract class ToolBarActivity extends BaseActivity {
    private ToolBarHelper mToolBarHelper;
    public Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void setContentView(int layoutResID) {

        mToolBarHelper = new ToolBarHelper(this, layoutResID);
        toolbar = mToolBarHelper.getToolBar();
        setContentView(mToolBarHelper.getContentView()); /*把 toolbar 设置到Activity 中*/
        setSupportActionBar(toolbar); /*自定义的一些操作*/
        onCreateCustomToolBar(toolbar);
//        toolbar.setLogo(R.mipmap.ic_launcher);//设置Logo
    }

    public void onCreateCustomToolBar(Toolbar toolbar) {
        toolbar.setContentInsetsRelative(0, 0);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            setResult(RESULT_OK);//多条件查询页面返回主页刷新
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
